﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FJERP.BLL;
using FJERP.Model;


namespace FJERP
{
    public partial class Users_Show : System.Web.UI.Page
    {
        MemberCardBLL bll = new MemberCardBLL();

        protected void VipLoad()
        {
            this.AspNetPager1.RecordCount = bll.Count();
            this.AspNetPager1.PageSize = 3;
            this.Repeater1.DataSource = bll.ShowMemberCard(3,this.AspNetPager1.CurrentPageIndex);
            this.Repeater1.DataBind();
            Label1.Text = bll.Count().ToString();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
            {
                VipLoad();
            }
        }

        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string name = e.CommandName;
            string vpid = e.CommandArgument.ToString();
            switch(name)
            {
                case "del":
                    if(bll.Del(Convert.ToInt32(vpid))>0)
                    {
                        Response.Write("<script>alert('删除成功!!!')</script>");
                        VipLoad();
                    }
                    else
                    {
                        Response.Write("<script>alert('删除失败!!!')</script>");
                    }
                    break;
                case "upt":
                    Response.Redirect("UsersEdit.html?id=" + vpid);
                    break;
            }

        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            VipLoad();
        }

        protected void Unnamed_ServerClick(object sender, EventArgs e)
        {
            this.AspNetPager1.RecordCount = bll.Count();
            this.AspNetPager1.PageSize = 3;
            this.Repeater1.DataSource = bll.ShowMemberCard_Sel(3, this.AspNetPager1.CurrentPageIndex, this.MemberCard_owner.Value, this.MemberCard_Name.Value);
            this.Repeater1.DataBind();
        }
    }
}